package com.example.javabase.threadLocal;

/**
 * @author haitao
 * @date 2021/11/8 4:45 下午
 */
public class Demo {
    public static void main(String[] args) throws InterruptedException {
        firstStack();
        System.gc();
        Thread thread = Thread.currentThread();
        System.out.println(thread);
    }
    private static A firstStack(){
        A a = new A();
        System.out.println("value: "+ a.get());
        return a;
    }
    private static class A{
        private final ThreadLocal<String> local = ThreadLocal.withInitial(() -> "纵横");
        public String get(){
            return local.get();
        }
        public void set(String str){
            local.set(str);
        }
    }
}
